package com.benshou.bsoa.dao;

import com.benshou.bsoa.common.dao.AbstractBaseModelDaoImpl;
import com.benshou.bsoa.dao.params.TestParams;
import com.benshou.bsoa.mapper.TestMapper;
import com.benshou.bsoa.model.Test;
import jakarta.annotation.Nullable;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author <a href="mailto:liuzhenbang@benshou.com">Liu Zhenbang</a>
 */
@Component
@RequiredArgsConstructor
public class TestDao extends AbstractBaseModelDaoImpl<TestMapper, Test> {

    @Override
    protected Test getEmptyModel() {
        return new Test();
    }

    public @Nullable Test getByTestNo(@NonNull String testNo) {
        return getOne(
                TestParams.builder()
                        .testNo(testNo)
                        .build()
        );
    }

    public boolean insertTest(@NonNull Test test) {
        return save(test); // AbstractBaseModelDaoImpl 提供的通用保存方法
    }
}
